/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package database;

import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
import model.Dokument;
import model.Surat;

/**
 *
 * @author priska
 */
public class DokumentTabel extends AbstractTableModel {

    private String columns[] = {"NomorDokumen", "Perihal", "AsalDokumen", "Penerima", "Letak", "NamaPetugas", "TanggalTerima", "Keterangan"};
    private ArrayList<Dokument> data;

    public DokumentTabel() {
    }

    public DokumentTabel(ArrayList<Dokument> data) {
        this.data = data;
    }

    @Override
    public int getRowCount() {
        return getData().size();
    }

    public String[] getColumns() {
        return columns;
    }

    @Override
    public int getColumnCount() {
        return getColumns().length;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Dokument doc = getData().get(rowIndex);
        if (columnIndex == 0) {
            return doc.getNoDokument();
        } else if (columnIndex == 1) {
            return doc.getPerihal();
        } else if (columnIndex == 2) {
            return doc.getAsalDokument();
        } else if (columnIndex == 3) {
            return doc.getPenerimaDokument();
        } else if (columnIndex == 4) {
            return doc.getLetakDokument();
        } else if (columnIndex == 5) {
            return doc.getPetugasPenerimaDokument();
        } else if (columnIndex == 6){
          return doc.getTanggal();
        }else{
            return doc.getKeterangan();
        }
    }

    public void setColumns(String[] columns) {
        this.columns = columns;
    }

    public ArrayList<Dokument> getData() {
        return data;
    }

    public void setData(ArrayList<Dokument> data) {
        this.data = data;
    }
}
